﻿
Namespace locks
    Public Structure spinlock
        Implements ilock

        Private se As singleentry

        Shared Sub New()
            yield()
        End Sub

        Public Sub [exit]() Implements ilock.exit
            se.release()
        End Sub

        Public Sub enter() Implements ilock.enter
            strict_wait_until(Function(ByRef s As singleentry) As Boolean
                                  Return s.mark_in_use()
                              End Function,
                              se)
        End Sub

        Public Function thread_owned() As Boolean Implements ilock.thread_owned
            Return False
        End Function
    End Structure
End Namespace
